package com.webchat.rmi.user;


import com.webchat.common.bean.APIPageResponseBean;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.domain.vo.request.CreateGroupRequestVO;
import com.webchat.domain.vo.response.AccountRelationResponseVO;
import com.webchat.domain.vo.response.UserBaseResponseInfoVO;
import com.webchat.domain.vo.response.WaitConfirmUserResponseVO;
import com.webchat.rmi.interceptor.RpcRequestInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(name = "webchat-user-service", contextId = "accountRelationClient", configuration = RpcRequestInterceptor.class)
public interface AccountRelationClient {

    /**
     * 订阅/关注
     *
     * @param sourceAccount
     * @param targetAccount
     * @return
     */
    @PostMapping("/user-service/account-relation/subscribe/{sourceAccount}/{targetAccount}")
    APIResponseBean<Boolean> subscribe(@PathVariable String sourceAccount,
                                       @PathVariable String targetAccount);

    /**
     * 取消订阅/关注
     *
     * @param sourceAccount
     * @param targetAccount
     * @return
     */
    @PostMapping("/user-service/account-relation/unsubscribe/{sourceAccount}/{targetAccount}")
    APIResponseBean<Boolean> unsubscribe(@PathVariable String sourceAccount,
                                         @PathVariable String targetAccount);

    /**
     * 同意好友关系
     *
     * @param relationId
     * @return
     */
    @PostMapping("/user-service/account-relation/confirmSubscribe/{confirmAccount}/{relationId}")
    APIResponseBean<Boolean> confirmSubscribe(@PathVariable String confirmAccount, @PathVariable Long relationId);

    /**
     * 拒绝好友
     *
     * @param relationId
     * @return
     */
    @PostMapping("/user-service/account-relation/rejectSubscribe/{rejectAccount}/{relationId}")
    APIResponseBean<Boolean> rejectSubscribe(@PathVariable String rejectAccount, @PathVariable Long relationId);

    /**
     * 分页获取账号关系列表
     *
     * @param account
     * @param type
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/user-service/account-relation/page")
    APIPageResponseBean<UserBaseResponseInfoVO> pageRelations(
            @RequestParam String account, @RequestParam Integer type,
            @RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize);

    /**
     * 查询用户关注列表（用户、机器人、公众号、群组）
     * @param account
     * @return
     */
    @GetMapping("/user-service/account-relation/list/{account}")
    APIResponseBean<AccountRelationResponseVO> listRelations(@PathVariable String account);

    /**
     * 查询待审核好友列表
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/account-relation/wait-confirm/list/{account}")
    APIResponseBean<List<WaitConfirmUserResponseVO>> listWaitConformUsers(@PathVariable String account);

    /**
     * 创建群聊
     *
     * @param createGroupRequest
     * @return
     */
    @PostMapping("/user-service/account-relation/createGroup")
    APIResponseBean<String> createChatGroup(@RequestBody CreateGroupRequestVO createGroupRequest);
}
